package com.bawei.week.adapter

import android.graphics.Color
import android.widget.TextView
import com.bawei.lib_base.entity.RepairBeanItem
import com.bawei.week.R
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder

class RepairAdapter : BaseQuickAdapter<RepairBeanItem,BaseViewHolder>(R.layout.item_repair){
    override fun convert(helper: BaseViewHolder, item: RepairBeanItem) {
        helper.setText(R.id.repair_order_number,"工单号:${item.orderNumber}")
        helper.setText(R.id.repair_time,"报修时间:${item.repairTime}")
        helper.setText(R.id.repair_name,"报修人:${item.repairName}")
        helper.setText(R.id.repair_contact_method,"联系电话:${item.contactMethod}")
        helper.setText(R.id.repair_location,"位置:${item.repairLocation}")
        helper.setText(R.id.repair_fault_description,"报修描述:${item.faultDescription}")

        val status = helper.getView<TextView>(R.id.repair_processing_status)
        status.text = item.processingStatus

        if (item.processingStatus == "待处理"){
            status.setBackgroundResource(R.drawable.shape_spare)
            status.setTextColor(Color.GREEN)
        }else if (item.processingStatus == "处理中"){
            status.setBackgroundResource(R.drawable.shape_occupied)
            status.setTextColor(Color.BLUE)
        }else if (item.processingStatus == "已完成"){
            status.setBackgroundResource(R.drawable.shape_under_repair)
            status.setTextColor(Color.DKGRAY)
        }
    }
}